package com.potenza.training.reply.controller;

import com.potenza.training.reply.entity.KeyWordEntity;
import com.potenza.training.reply.service.KeyWordService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;



/**
 * 分词表
 *
 * @author lihonggang
 * @email lihonggang@gmail.com
 * @date 2021-07-22 15:57:42
 */
@RestController
@RequestMapping("reply/keyword")
public class KeyWordController {
    @Autowired
    private KeyWordService keyWordService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("reply:keyword:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = keyWordService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("reply:keyword:info")
    public R info(@PathVariable("id") Long id){
		KeyWordEntity keyWord = keyWordService.getById(id);

        return R.ok().put("keyWord", keyWord);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("reply:keyword:save")
    public R save(@RequestBody KeyWordEntity keyWord){
		keyWordService.save(keyWord);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("reply:keyword:update")
    public R update(@RequestBody KeyWordEntity keyWord){
		keyWordService.updateById(keyWord);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("reply:keyword:delete")
    public R delete(@RequestBody Long[] ids){
		keyWordService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
